﻿using Microsoft.Build.Evaluation;
using NuGet;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OD.ProjectCustomizationTool.Helpers
{
    internal static class IPackageFileExtensions
    {
        /// <summary>
        /// Retrieve the full path to a package file from the given project.
        /// </summary>
        /// <param name="packageFile">The package considered file ;</param>
        /// <param name="project">The project from which to search.</param>
        /// <param name="packageMetadata">The package metadata of the project.</param>
        /// <returns>Returns the relative path from the current project to the package file.</returns>
        public static String GetFullPath(this IPackageFile packageFile, Project project, IPackageMetadata packageMetadata)
        {
            if (project == null)
            {   // This code has been generated from the 'argnull' custom snippet.
                throw new ArgumentNullException("project");
            }
            if (packageMetadata == null)
            {   // This code has been generated from the 'argnull' custom snippet.
                throw new ArgumentNullException("packageMetadata");
            }

            return Path.Combine(
                packageMetadata.FullPath(project),
                packageFile.Path);
        }
    }
}
